﻿<!--
 * Copyright © 2013-2015 Vahid Jalili
 * 
 * This file is part of MuSERA project.
 * MuSERA is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 * MuSERA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with Foobar. If not, see http://www.gnu.org/licenses/.
 *
-->
    
    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <SolidColorBrush x:Key="DataGridBackground">Transparent</SolidColorBrush>
    <SolidColorBrush x:Key="DataGridBorderBrush">#FF9FAAB4</SolidColorBrush>

    <Color x:Key="ColumnHeaderBackColor">#FF2E3438</Color>
    <Color x:Key="ColumnHeaderBorderColor">#FF545454</Color>    <!--the value #FF545454 was without FF-->
    <SolidColorBrush x:Key="ColumnHeaderForeColor">#FF9FAAB4</SolidColorBrush>

    <SolidColorBrush x:Key="RowBorderBrush">Orange</SolidColorBrush>

    <SolidColorBrush x:Key="RowForeground">Black</SolidColorBrush>
    <SolidColorBrush x:Key="RowBackground">Transparent</SolidColorBrush>
    <SolidColorBrush x:Key="AlternativeRowBackColor">#FF58C9FD</SolidColorBrush>
    <Color x:Key="HighlightBrush">OrangeRed</Color>


    <Color x:Key="DatagridCurrentCellBorderColor">Transparent</Color>

    <Style TargetType="{x:Type DataGrid}" BasedOn="{StaticResource {x:Type DataGrid}}">
        <Setter Property="Foreground" Value="{DynamicResource RowForeground}"/>
        <Setter Property="Background" Value="{DynamicResource DataGridBackground}"/>
        <Setter Property="RowBackground" Value="{DynamicResource RowBackground}"/>
        <Setter Property="AlternationCount" Value="2"/>
        <Setter Property="AlternatingRowBackground" Value="{DynamicResource AlternativeRowBackColor}"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="AutoGenerateColumns" Value="False"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="HeadersVisibility" Value="Column"/>
        <Setter Property="GridLinesVisibility" Value="None"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource DataGridBorderBrush}"/>
        <Setter Property="CanUserResizeRows" Value="False"/>
        <Setter Property="CanUserAddRows" Value="False"/>
        <Setter Property="CanUserResizeColumns" Value="True"/>
        <Setter Property="CanUserReorderColumns" Value="True"/>
        <Setter Property="RowHeight" Value="28"/>
        <Setter Property="MinRowHeight" Value="28"/>
        <Setter Property="IsReadOnly" Value="False"/>
        <Setter Property="SelectionMode" Value="Extended"/>
        <Setter Property="SelectionUnit" Value="FullRow"/>
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{StaticResource HighlightBrush}" />
        </Style.Resources>

    </Style>

    <!--Style and template for the resize control on the DataGridColumnHeader.-->
    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Cursor" Value="SizeWE" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Style and template for the DataGridColumnHeader.-->
    <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
        <Setter Property="Height" Value="25"/>
        <Setter Property="Foreground" Value="{DynamicResource ColumnHeaderForeColor}"/>
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Border x:Name="columnHeaderBorder" BorderThickness="1" Padding="3,0,3,0">
                            <Border.BorderBrush>
                                <SolidColorBrush Color="{DynamicResource ColumnHeaderBorderColor}"/>
                            </Border.BorderBrush>
                            <Border.Background>
                                <SolidColorBrush Color="{DynamicResource ColumnHeaderBackColor}"/>
                            </Border.Background>
                            <ContentPresenter HorizontalAlignment="Center"  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}" />
                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource {x:Type DataGridCell}}">
        <Setter Property="TextBlock.TextAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="Transparent" BorderThickness="0">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="Focused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CurrentStates">
                                <VisualState x:Name="Regular" />
                                <VisualState x:Name="Current">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource DatagridCurrentCellBorderColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>